package com.zhen.Mapper;

import com.zhen.User.Score;
import com.zhen.User.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
    @Select("select * from student")
    public List<Student> selectStudent();
    @Select("select count(*) from student")
    public int countStudent();
    @Select("select * from student limit #{begin},#{end}")
    public List<Student> selectStudentpage(@Param("begin") Integer begin,@Param("end") Integer end);
//更新学生信息
    @Update("update student set name=#{name},sex=#{sex},classroom=#{classroom}," +
            "teacher=#{teacher},address=#{address},dianhua=#{dianhua},jianjie=#{jianjie}," +
            "img=#{img} where id=#{id}")
    public Integer updateStudent(Student student);
//    更新学生成绩
    @Update("update score set name=#{name},classroom=#{classroom}," +
        "class1=#{class1},class2=#{class2},class3=#{class3},class4=#{class4} " +
        "where id=#{id}")
public Integer updateScore(Score score);
    //添加学生
    @Insert("insert into student(name,sex,classroom,teacher,date,address,dianhua,jianjie,img,password)"+
            "values(#{name},#{sex},#{classroom},#{teacher},#{date},#{address},#{dianhua},#{jianjie},#{img},#{password})")
            public int jiaStudent(Student student);
    @Insert("insert into score(name,classroom,class1,class2,class3,class4) " +
            "values(#{name},#{classroom},0,0,0,0)")
    public Integer insertScore(Student student);
    //重置学生密码
    @Update("update student set password='123456' where id=#{id}" )
    public int updatePassword(@Param("id") Integer id);
    //查学生信息分页
    List<Student> insertStudent(@Param("id") Integer id,@Param("name") String name,@Param("classroom") String classroom,@Param("sex") String sex,@Param("begin") Integer begin,@Param("end") Integer end);
    //查总和
    Integer countcha(@Param("id") Integer id,@Param("name") String name,@Param("classroom") String classroom,@Param("sex") String sex);
    //查学生成绩分页
    List<Score> scoreselect(@Param("id") Integer id,@Param("name") String name,@Param("classroom") String classroom,@Param("begin") Integer begin,@Param("end") Integer end);
    //查总和
    Integer countscore(@Param("id") Integer id,@Param("name") String name,@Param("classroom") String classroom);
    Integer delstudent(@Param("list") List<Integer> list);
}
